<template>
  <div>
    <div>
      <h3>赎回已被超过的出价 或 收益 ( 赎回前请先去 账户管理-解锁账户取得私钥 )</h3>
      <el-input style="width: 800px" placeholder="请输入私钥" v-model="privateKey">
        <template slot="prepend">私钥：</template>
      </el-input><br><br>
      <el-input style="width: 800px" placeholder="请输入合约地址" v-model="contractAddress">
      <template slot="prepend">合约地址：</template>
     </el-input><br><br>
      <el-button type="primary" @click="paiMaiWithdraw">赎回出价</el-button>
      <el-button type="primary" @click="paiMaiClose">赎回收益</el-button>
      <div>
        <el-descriptions column=1 title="赎回结果">
          <el-descriptions-item label="message">{{withdraw.message}}</el-descriptions-item>
          <el-descriptions-item label="status">{{withdraw.status}}</el-descriptions-item>
        </el-descriptions>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "paiMaiWithdraw",
  data() {
    return {
      privateKey: '',
      contractAddress: '',
      withdraw: '',
    }
  },

  methods: {
    paiMaiWithdraw() {
      this.axios.post("/paiMaiWithdraw", {
        privateKey: this.privateKey,
        contractAddress: this.contractAddress,
      }).then(res => {
        if (res.data.code == 200) {
          this.withdraw = res.data;
        }else {
          alert(res.data.message);
        }
      })
    },
    paiMaiClose() {
      this.axios.post("/paiMaiClose", {
        privateKey: this.privateKey,
        contractAddress: this.contractAddress,
      }).then(res => {
        if (res.data.code == 200) {
          this.withdraw = res.data;
        }else {
          alert(res.data.message);
        }
      })
    },
  },
}
</script>

<style scoped>

</style>

